package com.zjitc.obj;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/5 14:49
 * @description:
 */
public class User {
  private  String name;
  private Integer age;
  private Home home;

  public User() {
    this("xiaogou",21);
  }

  public User(String name, Integer age) {
    this.name = name;
    this.age = age;
  }

  public User(String name, Integer age, Home home) {
    this.name = name;
    this.age = age;
    this.home = home;
  }

  public void init(){
    System.out.println("init");
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public Integer getAge() {
    return age;
  }

  public void setAge(Integer age) {
    this.age = age;
  }

  public Home getHome() {
    return home;
  }

  public void setHome(Home home) {
    this.home = home;
  }

  public void destroy(){
  System.out.println("destroy");
}

  @Override
  public String toString() {
    return "User{" +
        "name='" + name + '\'' +
        ", age=" + age +
        ", home=" + home +
        '}';
  }
  public static User createInstance(Integer age) {
    if (age > 100) {
      return new User("bigger than 100", age);
    } else {
      return new User("smaller than 100", age);
    }
  }
}
